package com.pirestupppai.ui.activity;

import android.content.Context;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;

import com.pirestupppai.R;
import com.pirestupppai.adapter.FragmentAdapter;
import com.pirestupppai.base.BaseActivity;
import com.pirestupppai.ui.fragment.VideoMineFragment;
import com.pirestupppai.ui.fragment.VideoRecommendFragment;

import butterknife.BindView;

/**
 * 视频列表
 *
 * author: xiaoluo
 * date: 2017/5/23 14:05
 */
public class VideoListActivity extends BaseActivity{

    @BindView(R.id.video_tab_layout)
    TabLayout tabLayout;
    @BindView(R.id.video_viewpager)
    ViewPager viewPager;
    @BindView(R.id.back_btn)
    ImageView backBtn;

    private FragmentAdapter mFragmentAdapter;

    @Override
    protected Context getActivityContext() {
        return this;
    }

    @Override
    protected int loadParentLayout() {
        return R.layout.activity_video_list;
    }

    @Override
    protected void initViews() {
        mFragmentAdapter = new FragmentAdapter(getSupportFragmentManager());
        mFragmentAdapter.addFragment(new VideoMineFragment(), "我的");
        mFragmentAdapter.addFragment(new VideoRecommendFragment(), "推荐");
        viewPager.setAdapter(mFragmentAdapter);
        viewPager.setOffscreenPageLimit(1);
        // 将TabLayout与viewpager绑定
        tabLayout.setupWithViewPager(viewPager);

//        tabLayout.post(new Runnable() {
//            @Override
//            public void run() {
//                TabLayoutHelper.setIndicatorWidth(tabLayout,60,60);
//            }
//        });
    }

    @Override
    protected void initListeners() {
        backBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    protected void initLogic() {

    }

    @Override
    public void onClick(View v) {

    }
}
